package com.zeus.elasticsearch.espojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author 冯扬龙
 * @date 2022/5/3 12:59
 */


/**
 * 将pojo类对象转化成ES中的一条文档进行录入
 */
@Document(indexName = "test_index" , createIndex = true)
public class ElasticTest {

    /**
     * document中的值，indexname为需要创建索引的名字，createIndex为是否创建索引
     *
     * Field中对字段的数据类型进行设置，也可以选择一下使用哪种分词器
     */
    @Id
    private Integer id;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String name;
    @Field(type = FieldType.Integer)
    private Integer age;
    @Field(type = FieldType.Text)
    private String address;

    public ElasticTest(){}

    public ElasticTest(Integer id, String name, Integer age, String address) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}
